﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE;

namespace BLL
{
	public class EdgeGraph : Edge
	{
		public GraphVertex V1;
		public GraphVertex V2;
		private int totalWeight;
		public int TotalWeight
		{
			get
			{
				if ( totalWeight == 0 )
					return Weight;
				return totalWeight;
			}
			set { totalWeight = value; }
		}
		public EdgeGraph( int cid, string cname, string cdirection, GraphVertex cl1, GraphVertex cl2, bool cstraight, int cweight )
			: base()
		{
			ID = cid;
			Name = cname;
			Direction = cdirection;
			V1 = cl1;
			V2 = cl2;
			L1 = cl1.ID;
			L2 = cl2.ID;
			Straight = cstraight;
			Weight = cweight;
			totalWeight = 0;

		}
		public EdgeGraph( Edge edge, Vertex cl1, Vertex cl2 )
			: base( edge.ID, edge.Name, edge.Direction, edge.L1, edge.L2, edge.Straight, edge.Weight )
		{
			totalWeight = 0;
			V1 = new GraphVertex( cl1 );
			V2 = new GraphVertex( cl2 );
			L1 = cl1.ID;
			L2 = cl2.ID;
			
		}

		public EdgeGraph( int cid, string cname, string cdirection, GraphVertex cl1, GraphVertex cl2, bool cstraight, int cweight, int ctotalWeight )
			: base()
		{
			ID = cid;
			Name = cname;
			Direction = cdirection;
			V1 = cl1;
			V2 = cl2;
			L1 = cl1.ID;
			L2 = cl2.ID;
			Straight = cstraight;
			Weight = cweight;
			totalWeight = ctotalWeight;
		}
		public string GetTreeID
		{
			get { return base.L1 + "$" + base.L2; }
		}

		public static string CalculateTreeID( int n1, int n2 )
		{
			return n1 + "$" + n2;
		}


		public EdgeGraph CloneMe()
		{
			return new EdgeGraph( ID, Name, Direction, V1, V2, Straight, Weight,totalWeight);
		}

		internal Edge ToEdge()
		{
			return new Edge( ID, Name, Direction, L1, L2, Straight, Weight );
		}
	}
}
